package cn.iocoder.yudao.module.design.dal.mysql.useraccount;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.design.controller.admin.useraccount.vo.UserAccountExportReqVO;
import cn.iocoder.yudao.module.design.controller.admin.useraccount.vo.UserAccountPageReqVO;
import cn.iocoder.yudao.module.design.dal.dataobject.useraccount.UserAccountDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 用户账户信息 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface UserAccountMapper extends BaseMapperX<UserAccountDO> {

    default PageResult<UserAccountDO> selectPage(UserAccountPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<UserAccountDO>()
                .eqIfPresent(UserAccountDO::getUserId, reqVO.getUserId())
                .eqIfPresent(UserAccountDO::getCnt, reqVO.getCnt())
                .eqIfPresent(UserAccountDO::getAmount, reqVO.getAmount())
                .eqIfPresent(UserAccountDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(UserAccountDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(UserAccountDO::getId));
    }

    default List<UserAccountDO> selectList(UserAccountExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<UserAccountDO>()
                .eqIfPresent(UserAccountDO::getUserId, reqVO.getUserId())
                .eqIfPresent(UserAccountDO::getCnt, reqVO.getCnt())
                .eqIfPresent(UserAccountDO::getAmount, reqVO.getAmount())
                .eqIfPresent(UserAccountDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(UserAccountDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(UserAccountDO::getId));
    }

}
